package com.leetcode.algorithm.y22.m06;

/**
 * 392. 判断子序列
 * 
 * https://leetcode.cn/problems/is-subsequence/
 * 
 * @author jie.deng
 *
 */
class Question0392Solution02 {
	
	// DP
	public boolean isSubsequence(String s, String t) {
		int lenS = s.length();
		int lenT = t.length();
		int si = 0;
		int ti = 0;
		while (si < lenS) {
			while (ti < lenT && s.charAt(si) != t.charAt(ti)) {
				ti++;
			}
			if (ti >= lenT) {
				return false;
			}
			si++;
			ti++;
		}
		return true;
	}
    
}